package com.baizhi.cmfz.service.impl;

import com.baizhi.cmfz.dao.LogDao;
import com.baizhi.cmfz.entity.Log;
import com.baizhi.cmfz.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * This is a Class.
 *
 * @author zhanglh
 * @date 2019/09/18
 */
@Service
public class LogServiceImpl implements LogService {
    @Autowired
    private LogDao logDao;

    @Override
    public void addLog(Log log) {
        logDao.insertLog(log);
    }

    @Override
    public Map selectAllLog(String logType, String logContent, int page, int limit) {
        page = (page - 1) * limit;
        Map<String, Object> map = new HashMap<>();
        map.put("data", logDao.selectAllLog(logType, logContent, page, limit));
        map.put("count", logDao.countLog(logType, logContent));
        map.put("code", 0);
        return map;
    }
}
